using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DataAccessLayer
{
    public class DAO_Content
    {
        public static bool Insert(Object tmp)
        {
            CONTENT obj = (CONTENT)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@_TABLE__PK", obj._TABLE__PK));
            _list.Add(new SqlParameter("@CONTENT_DESC", obj.CONTENT_DESC));
            _list.Add(new SqlParameter("@CONTENT_NAME", obj.CONTENT_NAME));
            _list.Add(new SqlParameter("@COURSE_ID", obj.CONTENT_ID));
            int n = clsDataAccessHelper.ExecNonQuery("sp_content_insert", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Update(Object tmp)
        {
            CONTENT obj = (CONTENT)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@_TABLE__PK", obj._TABLE__PK));
            _list.Add(new SqlParameter("@CONTENT_DESC", obj.CONTENT_DESC));
            _list.Add(new SqlParameter("@CONTENT_NAME", obj.CONTENT_NAME));
            _list.Add(new SqlParameter("@CONTENT_ID", obj.CONTENT_ID));
            int n = clsDataAccessHelper.ExecNonQuery("sp_content_update", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Delete(Object tmp)
        {
            CONTENT obj = (CONTENT)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            //_list.Add(new SqlParameter("@_TABLE__PK", obj._TABLE__PK));
            //_list.Add(new SqlParameter("@CONTENT_DESC", obj.CONTENT_DESC));
            //_list.Add(new SqlParameter("@CONTENT_NAME", obj.CONTENT_NAME));
            _list.Add(new SqlParameter("@CONTENT_ID", obj.CONTENT_ID));
            int n = clsDataAccessHelper.ExecNonQuery("sp_content_delete", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static List<CONTENT> LoadAll()
        {
            List<CONTENT> _list = new List<CONTENT>();
            //call stored getlist here
            return _list;
        }
    }
}
